package main

import (
	"fmt"
	"math/rand"
)

// 1.打印九九乘法表。如果可以要求间隔均匀
func main() {
	for i := 1; i <= 9; i++ {
		for j := 1; j <= i; j++ {
			fmt.Printf("%d*%d=%-3d", j, i, j*i)
		}
		fmt.Println()
	}

	//2.随机生成20以内的20个非0正整数，打印出来。对生成的数值，第单数个（不是索引）累加求和，第偶数个累乘求积。打印结果
	b := 0
	c := 1
	for i := 1; i <= 20; i++ {
		a := rand.Intn(20) + 1
		fmt.Printf("%d %d\n", i, a)
		if i&1 == 1 {
			b += a
		} else {
			c *= a
		}
	}
	fmt.Println("奇数和:", b, "偶数积:", c)

	//3.打印100以内的斐波那契数列

	var d, e, f int
	d, e = 1, 1
	for f = 0; f < 100; f++ {
		fmt.Printf("%d %d", f, d) //把序列也打印出来
		fmt.Println()
		d, e = e, d+e
	}

}
